'use strict'

define(['jquery', 'bootstrap', 'select2', 'datetimepicker'], function($) {
  
  return {
    init: function(data) {
      this.initPage(data.today);
    },
    
    initPage: function(today){
      $('.date').datetimepicker({
        format: 'yyyy-mm-dd',
        autoclose: true,
        language: 'zh-CN',
        todayBtn: 'linked',
        todayHighlight: true,
        pickerPosition: 'bottom-right',
        minView: 'month',
        startDate: '2017-07-21',
        endDate: today
      });

      $('select[name="site"]').select2({
        minimumResultsForSearch : -1,
        allowClear : false
      });

      $('select[name="coach"]').select2({
        minimumResultsForSearch : 5,
        allowClear : true
      });
      
      $('.btn-default').click(function(){
        window.location.href = window.__CTX__.root + '/bwh-reports/export?'+$('#bwh-report-form').serialize();
      });
    }
  }
})
